#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>
#include <set>

using namespace std;

#define MAXN 22
#define INF 0x3F3F3F3F

int N;
int D;
set<int> G[MAXN];
int G2[MAXN][MAXN];
bool BOOK[MAXN];
vector<int> his;
int cnt;

bool connected(int u, int v) {
    for (int k=1; k<=N; k++)
        for (int i=1; i<=N; i++)
            for (int j=1; j<=N; j++)
                if (G2[i][k] + G2[k][j] < G2[i][j])
                    G2[i][j] = G2[i][k] + G2[k][j];
    if (G2[u][v] < INF) return true;
    return false;
}

void DFS(int u, int v) {
    if (u == v) {
        for (int i=0; i<his.size(); i++) {
            printf("%d ", his[i]);
        }
        printf("%d\n", u);
        cnt++;
        return;
    }
    BOOK[u] = true;
    his.push_back(u);
    for (set<int>::iterator i=G[u].begin(); i!=G[u].end(); i++) {
        int a = *i;
        if (!BOOK[a]) {
            DFS(a, v);
        }
    }
    his.pop_back();
    BOOK[u] = false;
}

int main()
{
    //freopen("out.txt", "w", stdout);
    int T = 1;
    while (~scanf("%d", &D)) {
        for (int i=0; i<MAXN; i++) {
            G[i].clear();
        }
        memset(G2, 0x3F, sizeof(G2));
        N = 0;
        while (true) {
            int u, v;
            scanf("%d%d", &u, &v);
            if (u == 0 && v == 0) break;
            G[u].insert(v);
            G[v].insert(u);
            G2[u][v] = 1;
            G2[v][u] = 1;
            N = max(N, u);
            N = max(N, v);
        }
        if (D == 1) {
            printf("CASE %d:\n", T++);
            printf("1\n");
            printf("There are 1 routes from the firestation to streetcorner %d.\n", D);
            continue;
        }
        memset(BOOK, 0, sizeof(BOOK));
        if (!connected(1, D)) {
            printf("CASE %d:\n", T++);
            printf("There are 0 routes from the firestation to streetcorner %d.\n", D);
            continue;
        }
        /*for (int i=1; i<=N; i++) {
            if (G[i].size() > 1) {
                sort(G[i].begin(), G[i].end());
            }
        }*/
        memset(BOOK, 0, sizeof(BOOK));
        his.clear();
        cnt = 0;
        printf("CASE %d:\n", T++);
        DFS(1, D);
        printf("There are %d routes from the firestation to streetcorner %d.\n", cnt, D);
    }
    return 0;
}
